import { FC, useState } from 'react';
import { Card, Button, Space } from 'antd';
import { PlusOutlined, SearchOutlined } from '@ant-design/icons';
import request from 'umi-request';

const Index: FC = () => {
  const [loading, setLoading] = useState<boolean>(false);
  const fn = () => {
    setLoading(true);
    request
      .get(
        'http://api.k780.com/?app=weather.realtime&weaId=94&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json',
      )
      .then((response) => {
        console.log(response);
        setLoading(false);
      });
  };

  return (
    <Space direction="vertical" style={{ display: 'flex' }}>
      <Card title="基础按钮">
        <Space>
          <Button type="primary" size="large">
            Primary Button
          </Button>
          <Button>Default Button</Button>
          <Button type="dashed">Default Button</Button>
          <Button type="primary" danger>
            Primary
          </Button>
          <Button type="dashed" danger>
            Primary
          </Button>
          <Button type="primary" disabled>
            Primary(disabled)
          </Button>
        </Space>
      </Card>

      <Card title="图形按钮">
        <Space>
          <Button icon={<PlusOutlined />}>添加</Button>
          <Button type="primary" shape="circle" icon={<SearchOutlined />} />
        </Space>
      </Card>

      <Card title="Loading按钮">
        <Space>
          <Button type="primary" loading={loading} onClick={fn}>
            搜索
          </Button>
        </Space>
      </Card>
    </Space>
  );
};

export default Index;
